package com.example.firstdemo.ui.screens.pages.handover

import android.annotation.SuppressLint
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.firstdemo.ui.theme.AppTheme

@SuppressLint("UnusedBoxWithConstraintsScope")
@Composable
fun HandoverScreen(padding: PaddingValues = PaddingValues(0.dp)) {
//    var log by remember { mutableStateOf("") }
//    Column(Modifier.padding(paddingValues)) {
//        Text(log)
//        Box(
//            Modifier
//                .size(100.dp)
//                .background(Color.Red)
//                .pointerInput(Unit) {
//                    awaitPointerEventScope {
//                        while (true) {
//                            val event = awaitPointerEvent()
//                            // handle pointer event
//                            log = "${event.type}, ${event.changes.first().position}"
//                        }
//                    }
//                }
//        )
//    }
    Column(Modifier.fillMaxSize()) {
        BoxWithConstraints {
            val rectangleHeight = 100.dp
            if (maxHeight < rectangleHeight * 2) {
                Box(
                    Modifier
                        .size(50.dp, rectangleHeight)
                        .background(Color.Blue)
                )
            } else {
                Column {
                    Box(
                        Modifier
                            .size(50.dp, rectangleHeight)
                            .background(Color.Blue)
                    )
                    Box(
                        Modifier
                            .size(50.dp, rectangleHeight)
                            .background(Color.Gray)
                    )
                }
            }
        }
    }
}

@Preview(showBackground = true)
@Composable
fun GreetingPreview() {
    AppTheme {
        HandoverScreen()
    }
}